import { app } from "../app";
import { getInfos, saveInfos } from "../dao/info";

const infoRouter = () => {
  app.get("/info/get/all", async (req, res: any) => {
    const infos = await getInfos();
    return res.json({
      code: 200,
      message: "获取成功",
      data: infos,
    });
  });

  app.post("/info/save/all", async (req, res: any) => {
    const { infos } = req.body;
    const success = await saveInfos(infos);
   
    return res.json({
      code: success ? 200 : 500,
      message: success ? "保存成功" : "保存失败",
    });
  });
};

export default infoRouter;
